<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>垂直居中</title>
    <style>
        .div1{
            width:150px;
            height:150px;
            background-color: pink;
        }
        .div2{
            width:50px;
            height:50px;
            background-color: black;
            margin:auto 0;
        }
    </style>
</head>
<body>
<!--垂直居中方法-->
<!--定位-->
<!--margin:auto 0-->
<div class="div1">
    <div class="div2"></div>
</div>
</body>
</html>